const arr1 = [1, 3, 4, 6, 7]
const arr2 = [2, 5, 3, 6, 1]

function getIntersection(arr1, arr2) {
  // 交集...
  return [...new Set([...arr1, ...arr2])].filter((item) => {
    return arr1.includes(item) && arr2.includes(item)
  })
}

function getUnion(arr1, arr2) {
  // 并集...
  return [...new Set([...arr1, ...arr2])]
}

console.log(getIntersection(arr1, arr2))
console.log(getUnion(arr1, arr2))
